<template>
	<view>
		<view class="top">
			<view class="" style="display: flex;justify-content: center;position: relative;">
				<image src="https://oss.taoding1688.com/static/uniapp/static/images/mall/my/icon_20241123001.png "
					mode="widthFix" style="width: 500rpx;"></image>
				<view class=""
					style="position: absolute;bottom: 180rpx;font-size: 88rpx;font-weight: bold;color: #b83d19;" v-if="userInfo && userInfo.coin">
					{{(userInfo.coin/10000).toFixed(2) || 0}}
					<text style="font-size: 38rpx;">元</text>
				</view>


				<piaoyiProgressBar v-if="startPrice>=100000" :progress="100" backgroundColor="#cb752e"
					progressBackgroundColor="#Fae8c9"
					style="position: absolute;top: 250rpx;width: 230rpx;height: 20rpx;right: 300rpx;" textColor="#fff"
					:textSize="24" :height="20"></piaoyiProgressBar>

				<piaoyiProgressBar v-else :progress="progress" backgroundColor="#cb752e"
					progressBackgroundColor="#Fae8c9"
					style="position: absolute;top: 250rpx;width: 230rpx;height: 20rpx;right: 300rpx;" textColor="#fff"
					:textSize="24" :height="20"></piaoyiProgressBar>

				<view class="" @click="opendbShow"
					style="position: absolute;top: 245rpx;right: 200rpx;background: #fff;border-radius: 50rpx;font-size: 20rpx;color: #3593ff;padding: 2rpx 10rpx;">
					兑换红包</view>

				<!-- 	<view @click="opendbShow" v-if="startPrice<1000"
					style="position: absolute;top: 280rpx;border-radius: 50rpx;font-size: 28rpx;font-weight: bold;color: #Fae8c9;letter-spacing: 1rpx;">
					仅差<tn-count-to :startVal="startPrice" :endVal="endPrice" :fontSize="28" fontColor="#Fae8c9"
						:bold="true"></tn-count-to>涛币 <text class="tn-icon-right-triangle"></text> </view>
				<view @click="opendbShow" v-if="startPrice>=1000"
					style="position: absolute;top: 280rpx;border-radius: 50rpx;font-size: 28rpx;font-weight: bold;color: #Fae8c9;letter-spacing: 1rpx;">
					可以兑换</view> -->



			</view>
			<view class="" style="width: 100%;display: flex;justify-content: center;">
				<view class=""
					style="background: #fadace;padding: 0rpx 20rpx 20rpx 20rpx;width: 97%;border-radius: 20rpx;">
					<view class="" style="color: #582306;font-weight: bold;padding: 20rpx 0;">
						累计签到奖励( <text style="color: red;">{{ continue_days }}</text> /{{days.length}})</view>
					<view class="" style="display: flex;justify-content: space-between;width: 100%;">
						<scroll-view scroll-x style="width: 100%;" :scroll-into-view="scrollIntoViewId">
							<view class="tui-goods__list" style="width: 100%;">
								<view class="tui-goods__item tui-goods__list" v-for="(item, index) in days" :key="index"
									:id="'current'+index">
									<view class="tui-goods__imgbox" style="position: relative;">
										<image src="https://oss.taoding1688.com/static/uniapp/static/commission/zfb.jpg"
											mode="widthFix" style="width: 18rpx;"></image>
										<view style="font-size: 18rpx;font-weight: bold;">领现金</view>
										<view class="acIcon" style="" v-if="item.is_sign==1"><text
												class="tn-icon-success"
												style="font-weight: bold;font-size: 16rpx;color: #fff;"></text></view>
									</view>
									<view class="tui-pri__box">
										<view class="tui-sale-pri">
											<view class="" v-if="item.is_sign==1"
												style="font-size: 28rpx;color: #cd785e;width:200rpx;display: flex;justify-content: center;align-items: center;">
												<!-- <image src="../../static/taob.png" mode="widthFix"
													style="width: 60rpx;height: 60rpx;"></image>
												<view class=""
													style="position: absolute;top: 10rpx;font-weight: bold;font-size: 38rpx;color: red;">
													{{Number(rules.everyday)+index*Number(rules.inc_num)}}
												</view> -->
												<view class="" style="font-weight: bold;margin-top: 10rpx;">已领取</view>
											</view>
											<view class="" v-else
												style="position: relative;width:200rpx;display: flex;justify-content: center;align-items: center;">
												<image src="../../static/taob.png" mode="widthFix"
													style="width: 60rpx;height: 60rpx;"></image>
												<view class="" style="position: absolute;top: 10rpx;font-weight: bold;font-size: 38rpx;" v-if="index<=rules.until_day">
													{{Number(rules.everyday)+index*Number(rules.inc_num)}}
												</view>
												<view class="" style="position: absolute;top: 10rpx;font-weight: bold;font-size: 38rpx;" v-else>
													{{rules.everyday}}
												</view>
											</view>
											<!-- <view class="tui-size-sm">.50</view> -->
										</view>
									</view>

									<view class=""
										style="color: #cd785e;font-weight: bold;font-size: 30rpx;"
										v-if="item.current=='today'">今天</view>
									<view class=""
										style="color: #cd785e;font-weight: bold;padding-bottom: 10rpx;font-size: 30rpx;"
										v-else>第{{index+1}}天</view>
								</view>
							</view>
						</scroll-view>
						<!-- 	<view class="" style="flex: 1;width: 100%;">
							<view class=""
								style="background: #3593ff;width: 110rpx;height: 130rpx;margin: 0 15rpx;border-radius: 10rpx;padding-top: 8rpx;">
								<view class=""
									style="background: #fff;border-radius: 15rpx;display: flex;justify-content: center;align-items: center;flex-direction: column;width: 95rpx;padding: 8rpx 5rpx;margin: auto;">
									<image src="https://oss.taoding1688.com/static/uniapp/static/commission/zfb.jpg"
										mode="widthFix" style="width: 30rpx;height: 30rpx;"></image>
									<view class="" style="font-size: 22rpx;color: #3593ff;font-weight: bold;">现金奖励
									</view>
								</view>
								<view class=""
									style="color: #fff;font-weight: bold;font-size: 30rpx;text-align: center;">第7天
								</view>
							</view>
						</view> -->
					</view>
				</view>
			</view>
			<view style="display: flex;justify-content: space-around;margin-top: 40rpx;">
				<view @click="openNavtive"
					style="background: rgb(254, 228, 198);display: flex;justify-content: center;align-items: center;flex-direction: column;border-radius: 20rpx;position: relative;width: 160rpx;">
					<image src="../../static/taob.png" mode="widthFix" style="width: 50rpx;"></image>
					<view style="color: #ff3553;font-size: 28rpx;font-weight: bold;">赚涛币
					</view>
					<view class="iconBtn">+46</view>
				</view>
				<view @click="submitWeek"
					style="background:#ff3553;color: #fff;font-size: 44rpx;width: 320rpx;font-weight: 500;border-radius: 20rpx;display: flex;justify-content: center;align-items: center;">
					继续领钱</view>
				<view
					style="background: rgb(254, 228, 198);display: flex;justify-content: center;align-items: center;flex-direction: column;border-radius: 20rpx;position: relative;width: 160rpx;"
					@click.stop="openPrice">
					<image src="../../static/taob.png" mode="widthFix" style="width: 50rpx;"></image>
					<!-- <view class="" style="font-size: 24rpx;">00:00:00</view> -->

					<view class="" v-if="showTitle">
						<view style="color: #ff3553;font-size: 28rpx;font-weight: bold;">明天再来
						</view>
					</view>
					<view class="" v-else>
						<tn-count-down :timestamp="timestamp" @end="end" backgroundColor="none" :fontSize="24"
							v-if="endShow==false"></tn-count-down>
						<view v-else style="color: #ff3553;font-size: 28rpx;font-weight: bold;">{{text}}
						</view>
						<view class="iconBtn">+{{num}}</view>
					</view>
				</view>
			</view>
		</view>
		<view class="" style="width: 100%;display: flex;justify-content: center;">
			<view class="" style="width: 95%;">
				<view class=""
					style="border: 3rpx solid #ee7c44;margin-top: 30rpx;display: flex;justify-content: space-between;align-items: center;padding:0 10rpx;border-radius: 20rpx;">
					<view class="tn-icon-search" style="color: #ee7c44;font-size: 42rpx;margin: 0 10rpx;"></view>
					<view class="" style="width: 65%;">
						<tn-input v-model.trim="value" placeholder="清纯系掐腰裙" />
					</view>
					<view class=""
						style="background: #ed6c2c;color: #fff;font-size: 28rpx;padding:12rpx 25rpx;border-radius: 10rpx;">
						搜索</view>
				</view>
			</view>
		</view>
		<view
			style="background: #eb473f;position: fixed;right: 0;z-index: 800;padding: 5rpx;right: 15rpx;top: 70%;border-radius: 10rpx;"
			@click="bottomPopup" v-if="couponListMenu.length>=1">
			<view
				style="border-radius: 10rpx;color: red;background: #fff;padding: 12rpx 5rpx;text-align: center;font-size: 38rpx;border-bottom-left-radius:100rpx 30rpx;border-bottom-right-radius:100rpx 30rpx;">
				￥1</view>
			<view style="font-size: 24rpx;color: #fff;padding: 20rpx 0;">1天后失效</view>
		</view>
		<view class="tui-product-box" style="margin-top: 20rpx;">
			<view class="tui-product-list">
				<view class="tui-product-container">
					<block v-for="(item, index) in redList" :key="index" v-if="(index + 1) % 2 != 0">
						<!--商品列表-->
						<view class="tui-pro-item" hover-class="hover" :hover-start-time="150" @tap="detail(item)">
							<image :src="info.app.cdnurl+ item.image" class="tui-pro-img" lazy-load mode="widthFix" />
							<view class="tui-pro-content">
								<view class="tui-pro-tit">{{ item.title }}</view>
								<view>
									<view class="tui-pro-price">
										<text class="tui-sale-price">￥{{ item.price[0] }}</text>
										<text class="tui-sale-price"  v-if="item.is_coin==1" style="font-size: 24rpx;margin-left: 20rpx;">红包省{{item.coin_price }}元</text>
									</view>
								</view>
							</view>
						</view>
						<!--商品列表-->
						<!-- <template is="productItem" data="{{item,index:index}}" /> -->
					</block>
				</view>
				<view class="tui-product-container">
					<block v-for="(item, index) in redList" :key="index" v-if="(index + 1) % 2 == 0">
						<!--商品列表-->
						<view class="tui-pro-item" hover-class="hover" :hover-start-time="150" @tap="detail(item)">
							<image :src="info.app.cdnurl+ item.image" class="tui-pro-img" lazy-load mode="widthFix" />
							<view class="tui-pro-content">
								<view class="tui-pro-tit">{{ item.title }}</view>
								<view>
									<view class="tui-pro-price">
										<text class="tui-sale-price">￥{{ item.price[0] }}</text>
										<text class="tui-sale-price"  v-if="item.is_coin==1" style="font-size: 24rpx;margin-left: 20rpx;">红包省{{item.coin_price }}元</text>
									</view>
								</view>
							</view>
						</view>
						<!--商品列表-->
					</block>
				</view>
			</view>
		</view>
		<tn-popup v-model="redShow" mode="bottom" style="width: 90%;margin: auto;">
			<view class="" style="padding: 10rpx 0 80rpx 0;">
				<view class=""
					style="display: flex;justify-content: space-between;align-items: center;padding: 0 30rpx;">
					<view class="tn-icon-close" style="font-size: 38rpx;color: #000;font-weight: bold;opacity: 0;">
					</view>
					<view class="" style="text-align: center;font-size: 42rpx;font-weight: bold;margin: 30rpx 0;">我的红包
					</view>
					<view class="tn-icon-close" style="font-size: 38rpx;color: #000;font-weight: bold;"
						@click="redShow=false"></view>
				</view>
				<view class="" style="padding: 0 30rpx;">
					<view style="display: flex;">
						<view class="tn-icon-clock-fill" style="color: rgb(254, 98, 1);font-size: 42rpx;"></view>
						<view class="" style="font-size: 30rpx;">快去使用红包吧</view>
					</view>
					<view class="" style="max-height: 350rpx;overflow: auto;">
						<view
							style="display: flex;border-radius: 10rpx;border: 5rpx solid red;background: red;padding: 3rpx;margin-top: 30rpx;"
							v-for="(item,index) in couponListMenu" :key="index">
							<view class=""
								style="border-radius: 10rpx;color: red;font-size: 56rpx;background: #fff;padding: 30rpx 20rpx 30rpx 10rpx;display: flex;align-items: center;font-weight: bold;border-top-right-radius:30rpx 100rpx;border-bottom-right-radius:30rpx 100rpx;">
								<view class="" style="font-size: 38rpx;">￥</view> 1
							</view>
							<view class=""
								style="display: flex;flex-direction: column;color: #fff;color: #e8e8e8;font-size: 28rpx;justify-content: center;margin-left: 20rpx;">
								<view class="" style="font-size: 34rpx;">{{item.amount_text}}</view>
								<view class=""><tn-count-down :timestamp="item.timeDifference" showDays showHours showMinutes showSeconds separator="ch" backgroundColor="none" fontColor="#fff" separatorColor="#fff"></tn-count-down>后失效</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</tn-popup>


		<tn-popup v-model="dhShow" mode="bottom" style="width: 90%;margin: auto;">
			<view class="" style="background: rgb(254, 98, 0);">
				<view class=""
					style="display: flex;justify-content: space-between;align-items: center;padding: 0 30rpx;color: #fff;">
					<view class="tn-icon-close" style="font-size: 38rpx;color: #fff;font-weight: bold;opacity: 0;">
					</view>
					<view class="" style="text-align: center;font-size: 42rpx;font-weight: bold;margin: 30rpx 0;">
						攒满涛币兑换奖励
					</view>
					<view class="tn-icon-close" style="font-size: 38rpx;color: #fff;font-weight: bold;"
						@click="dhShow=false"></view>
				</view>
				<view class="" style="padding: 0 30rpx;display: flex;color: #fff;display: flex;align-items: center;">
					<image src="../../static/taob.png" mode="widthFix" style="width: 60rpx;height: 60rpx;"></image>
					<view class="">我的涛币</view>
				</view>
				<view class=""
					style="padding: 0 30rpx 30rpx 30rpx;display: flex;justify-content: space-between;margin: 10rpx 0;">
					<view class="" style="font-size: 88rpx;color: rgb(254, 225, 188);">
						{{userInfo.coin}}
					</view>
					<view class="" style="display: flex;align-items: center;">
						<text class="tn-icon-notice" style="color: rgb(254, 225, 188);"></text>
						<view class="" style="color: rgb(254, 225, 188);font-size: 26rpx;">30天未访问涛币清零</view>
					</view>
				</view>
			</view>
			<view class="" style="padding: 10rpx 20rpx 100rpx 20rpx;">
				<view class="" style="display: flex;align-items: center;">
					<view class="" style="font-size: 38rpx;">兑换红包</view>
					<view class="" style="font-size: 22rpx;margin-left: 20rpx;color: #666;">10000涛币=1元</view>
				</view>
				<view class="" style="margin-top: 20rpx;padding: 0 20rpx;">
					<view class="contents" style="margin-top: 20rpx;">
						<view class="items" v-for="(item,index) in couponList" :key="index">
							<view style="background: #ff3233;padding: 5rpx;width: 170rpx;border-radius: 10rpx;">
								<view class=""
									style="border-radius: 10rpx;background: #fff;border-bottom-right-radius:100rpx 30rpx;border-bottom-left-radius:100rpx 30rpx;color: #ff3233;padding: 30rpx 0 15rpx 0;font-size: 42rpx;font-weight: bold;text-align: center;">
									<text style="font-size: 30rpx;">￥</text> {{item.amount}}
								</view>
								<view
									style="height: 100rpx;display: flex;justify-content: center;align-items: center;color: #fff;font-size: 28rpx;">
									{{item.use_scope_text}}
								</view>
							</view>
							<view @click="exchange(item)" v-if="timeResult"
								style="width: 170rpx;text-align: center;padding: 8rpx 10rpx;margin-top: 15rpx;border-radius: 10rpx;font-size: 26rpx;background: #fe6100;color: #fff;">
								立即兑换</view>
							<view  v-else
								style="width: 170rpx;text-align: center;padding: 8rpx 10rpx;margin-top: 15rpx;border-radius: 10rpx;font-size: 26rpx;background: #f0f2f4;color: #000;">
								每天11点开抢</view>
						</view>
						
					</view>
				</view>
				<!-- <view style="display: flex;border-radius: 10rpx;border: 5rpx solid red;background: red;padding: 3rpx;margin-top: 30rpx;display: flex;flex-direction: column;">
					<view class=""
						style="color: red;font-size: 56rpx;background: #fff;padding: 30rpx 20rpx 30rpx 10rpx;display: flex;align-items: center;font-weight: bold;border-top-right-radius:30rpx 100rpx;border-bottom-right-radius:30rpx 100rpx;">
						<view class="" style="font-size: 38rpx;">￥</view> 0.35
					</view>
					<view class=""
						style="display: flex;flex-direction: column;color: #fff;color: #e8e8e8;font-size: 28rpx;justify-content: center;margin-left: 20rpx;">
						<view class="">频道专享红包，满xx元可用</view>
						<view class="">1天后失效</view>
					</view>
				</view> -->




			</view>
		</tn-popup>
		<kevy-mask :show="showSignBox" v-if="showSignBox" @click="closeSign" :maskClose="true" :z-index="10">
			<!-- <view v-if="showSignBox" class="t-overlay" @mousemove.stop @click="closeSign"> -->
			<view class="t-o-wrap">
				<image class="t-sign-bg"
					src="https://oss.taoding1688.com/static/uniapp/static/images/mall/my/icon_20241125001.png"></image>
				<view class="t-g-jf">+{{num}}涛币</view>
				<!-- <view class="t-g-desc">已连续签到{{dataList.continue_days}}天，继续签到有惊喜哦~</view> -->
				<view class="close-btn" @click="closeSign">确认</view>
			</view>
		</kevy-mask>
		<tn-popup v-model="navPopupShow" mode="bottom">
			<view style="padding: 50rpx 20rpx;background: linear-gradient(to right, #fa7850, #e9203d);">
				<view class="" style="display: flex;justify-content: space-between;color: #fff;align-items: center;">
					<text class="tn-icon-close" style="opacity: 0;"></text>
					<view class="" style="font-size: 48rpx;font-weight: 500;">做任务赚涛币</view>
					<text class="tn-icon-close" style="font-size: 48rpx;" @click="navPopupShow=false"></text>
				</view>
				<view class="" style="background: #fff;padding: 30rpx 0;margin-top: 30rpx;border-radius: 20rpx;">
					<view class=""
						style="margin: 20rpx 0;background: rgb(250, 250, 250);padding: 20rpx 20rpx;display: flex;justify-content: space-between;align-items: center;">
						<text class="tn-icon-trusty"></text>
						<view class="" style="flex: 1;padding: 0 20rpx;">
							<view class="" style="color: rgb(126, 70, 70);font-size: 36rpx;font-weight: bold;">
								逛精选好货赚涛币({{numTotal}}/5)
							</view>
							<view class="" style="color: #666;font-size: 26rpx;display: flex;align-items: center;">
								浏览30秒可得200涛币 <image src="../../static/taob.png" mode="widthFix"
									style="width: 40rpx;height: 40rpx;"></image>
							</view>
						</view>
						<view class=""
							style="background: rgb(236, 84, 84);color: #fff;padding: 13rpx 35rpx;border-radius: 40rpx;font-size: 30rpx;"
							@click="navigateShop">{{textBtn}}</view>
					</view>
				</view>
			</view>
		</tn-popup>
		<tn-popup v-model="popupShowPrice" mode="center" length="75%" :borderRadius="20">
			<view style="background: #ff3732;width: 100%;padding: 10rpx;border-radius: 20rpx;padding-bottom: 50rpx;">
				<view class=""
					style="background: #fff;border-radius: 20rpx;padding-bottom: 40rpx;border-bottom-left-radius: 50% 60rpx;border-bottom-right-radius: 50% 60rpx;position: relative;">
					<view class="" style="display: flex;justify-content: center;">
						<view class=""
							style="text-align: center;background: #ffe8e5;display: block;padding: 8rpx 55rpx;color: #ff3732;font-weight: bold;border-bottom-left-radius:50rpx 100rpx;border-bottom-right-radius:50rpx 100rpx;">
							签到领红包
						</view>
					</view>
					<view class=""
						style="display: flex;justify-content: center;align-items: center;color: #ff3732;margin: 10rpx 0;">
						<view class="">￥</view>
						<view class="" style="font-size: 88rpx;font-weight: bold;font-weight: bold;">
							{{detailViewDetail.amount}}
						</view>
					</view>
					<view class="" style="text-align: center;color: #ff3732;">{{detailViewDetail.name}}</view>
				</view>
				<view class="" style="display: flex;flex-direction: column;margin-top: 50rpx;">
					<view class="" style="text-align: center;color: #fff;font-size: 46rpx;">恭喜获得签到红包</view>
					<view class="" style="text-align: center;color: #fff;margin-top: 30rpx;"> <tn-count-down
							separatorColor="#fff" backgroundColor="none" fontColor="#fff"
							:timestamp="timestampCoupon"></tn-count-down>后失效</view>
					<view class=""
						style="text-align: center;background: rgb(255, 240, 233);width: 500rpx;margin: auto;margin-top: 60rpx;color: #ff3732;font-weight: bold;padding: 15rpx 0;font-size: 38rpx;border-radius: 10rpx;"
						@click="popupShowPrice=false">去使用</view>
				</view>
			</view>
		</tn-popup>
	</view>
</template>

<script>
	import {
		getActivitySigninWeek,
		getActivitySigninSignin,
		getUserProfile,
		getActivitySigninIncScore,
		getGoodsIds,
		getActivityScorecouponList,
		postShopExchangeScoreCoupon,
		getShopCoupon,
		getReceiveViewCoupon,
		getViewCouponList,
		getUserCoupon
	} from "@/apis/index.js"
	import piaoyiProgressBar from '../components/piaoyi-progress-bar.vue';
	import kevyMask from '../kevy-mask/kevy-mask.vue';
	export default {
		components: {
			piaoyiProgressBar,
			kevyMask
		},
		data() {
			return {
				rules: {},
				detailViewDetail: {},
				timestampCoupon: 86399,
				popupShowPrice: false,
				navPopupShow: false,
				showTitle: false,
				scrollIntoViewId: '',
				showSignBox: false,
				dhShow: false,
				redList: [],
				startPrice: 2999,
				endPrice: 4000,
				redShow: false,
				value: '',
				endShow: false,
				text: '点击领取',
				textBtn: '去逛逛',
				progress: 0,
				timestamp: 0,
				num: 1,
				continue_days: [],
				days: [],
				indexNum: 0,
				userInfo: {},
				couponList: [],
				goods_ids: '',
				time: [{
						timestamp: 30,
						num: 100
					},
					{
						timestamp: 60,
						num: 100
					},
					{
						timestamp: 120,
						num: 100
					},
					{
						timestamp: 300,
						num: 100
					},
					{
						timestamp: 10,
						num: 100
					}

				],
				timeResult: false,
				timer: null,
				couponListMenu: [],
			}
		},
		async onShow() {
			this.getSetInterval()
			await this.getUserInfo()
			let ress = this.getDataMonth()
			let month = uni.getStorageSync('month')

			if (ress == month) {
				let indexNum = uni.getStorageSync('indexNum')
				if (indexNum) {
					this.indexNum = indexNum
				}
				if (this.time[this.indexNum]) {
					this.timestamp = this.time[this.indexNum].timestamp
					this.num = this.time[this.indexNum].num
				} else {
					this.showTitle = true
				}
			} else {
				let indexNum = 0
				this.timestamp = this.time[indexNum].timestamp
				this.num = this.time[indexNum].num
				uni.setStorage({
					key: 'indexNum',
					data: indexNum
				})
			}

		},
		async onLoad() {
			await this.getCoupon()
			await this.getDataWeek()

			const date = new Date()
			const day = ('0' + date.getDate()).slice(-2); // 补零处理
			this.scrollIntoViewId = 'current' + day
			// let ids=this.info.template.home.data[22].data.goodsIds
			// console.log(ids,'idsidsidsidsidsids')
			// if(ids){

			// }
		},
		destroyed() {
			clearInterval(this.timer)
		},
		methods: {
			// getSetInterval() {
			getComputed(arr) {
				let lastContinuousSignOneStartIndex = -1;
				let lastContinuousSignOneEndIndex = -1;
				for (let i = arr.length - 1; i >= 0; i--) {
					if (arr[i].is_sign === 1) {
						lastContinuousSignOneStartIndex = i;
						break;
					}
				}
				if (lastContinuousSignOneStartIndex !== -1) {
					for (let i = lastContinuousSignOneStartIndex - 1; i >= 0; i--) {
						if (arr[i].is_sign !== 1) {
							lastContinuousSignOneStartIndex = i + 1;
							break;
						}
					}
					for (let i = lastContinuousSignOneStartIndex; i < arr.length; i++) {
						if (arr[i].is_sign !== 1) {
							lastContinuousSignOneEndIndex = i;
							break;
						}
					}
					if (lastContinuousSignOneEndIndex === -1) {
						lastContinuousSignOneEndIndex = arr.length;
					}
				}
				let resultData;
				if (lastContinuousSignOneStartIndex !== -1) {
					resultData = arr.slice(lastContinuousSignOneStartIndex);
				} else {
					resultData = [];
				}
				return resultData
			},
			//红包列表
			async getActivityCoupon() {
				let res = await getUserCoupon('geted', 10000, 1)
				if (res.code == 1) {
					let list = res.data.data
					this.couponListMenu = list.filter(item => {
						if (item.type == 'view') {
							
							
								 let  endTime = new Date(item.use_end_time);
							      let  currentTime  = new Date();
							
							      // 计算时间差（毫秒）
							      let diffInMilliseconds = endTime - currentTime ;
								
							      // 将毫秒转换为秒
							      item.timeDifference = Math.floor(diffInMilliseconds / 1000)
								  console.log(item.timeDifference)
							
							return item
						}
					})
				}

				console.log(res, '----------------------------')
				// this.couponListMenu=res.data
			},

			getSetInterval() {
				let ress = this.getDataMonth()
				let month = uni.getStorageSync('months')
				if (month && ress == month && this.numTotal >= 5) {
					this.textBtn = '已完成'
				} else {
					this.textBtn = '去逛逛'
					let _this = this
				}
				let isOk = uni.getStorageSync('isOk')
				if (isOk && isOk == ress) {
					this.textTrue = true
					this.getActivityCoupon()
					return
				} else {
					let num = 15
					this.timer = setInterval(() => {
						num = num - 1
						console.log(123123, num)
						if (num <= 0) {
							uni.setStorage({
								key: 'isOk',
								data: ress
							})
							clearInterval(this.timer)
							getReceiveViewCoupon(10).then(res => {
								if (res.code == 1) {
									this.detailViewDetail = res.data
									this.popupShowPrice = true
									this.getActivityCoupon()
								}
							})
						}
					}, 1000)
				}




			},
			navigateShop() {
				this.navPopupShow = false
					clearInterval(this.timer)
			},
			navigateShop() {
				this.navPopupShow = false
				clearInterval(this.timer)
				uni.navigateTo({
					url: `/discountPage/pointsMail/pointsMail?ids=${this.goods_ids}`
				})
			},
			//赚涛币
			openNavtive() {
				this.navPopupShow = true
			},
			checkTimeInRange() {
				const currentTime = new Date();
				const currentHour = currentTime.getHours();
				if (currentHour >= 11 && currentHour < 12) {
					this.timeResult = true;
				} else {
					this.timeResult = false;
				}
			},
			opendbShow() {
				this.dhShow = true
				this.checkTimeInRange()
			},
			async exchange(item) {
				let res = await postShopExchangeScoreCoupon(item.id)
				uni.showToast({
					title: res.msg,
					icon: 'none'
				})
				await this.getUserInfo()
			},
			async getCoupon() {
				let {
					code,
					data
				} = await getActivityScorecouponList()
				this.couponList = data.data
			},
			getUserInfo() {
				getUserProfile().then(res => {
					this.userInfo = res.data
					this.startPrice = this.userInfo.coin
					this.endPrice = 1000 - this.userInfo.coin
					this.progress = this.userInfo.coin / 1000
					this && this.$tn.vuex('userInfos', res.data)
				})
			},
			async openPrice() {
				if (this.endShow) {
					let res = await getActivitySigninIncScore(100)
					uni.showToast({
						title: res.msg,
						icon: 'none'
					})
					this.getUserInfo()
					this.endPrice = 1000 - this.endPrice + 5
					this.receive()
					let ress = this.getDataMonth()
					uni.setStorage({
						key: 'month',
						data: ress
					})
				} else {
					uni.showToast({
						title: '明天再来',
						icon: 'none'
					})
					return
				}
			},
			detail(item) {
				clearInterval(this.timer)
				uni.navigateTo({
					url: `/templatePage/productDetail/productDetail?index=${item.id}`
				});
			},
			bottomPopup() {
				this.redShow = true
			},
			getContinuousSignedData(arr) {
				let continuousSigned = false;
				let result = [];

				for (let i = 0; i < arr.length; i++) {
					if (arr[i].is_sign === 1) {
						if (!continuousSigned) {
							continuousSigned = true;
						}
						result.push(arr[i]);
					} else if (continuousSigned) {
						break;
					}
				}

				return result;
			},

			async getDataWeek() {
				let {
					code,
					data
				} = await getActivitySigninWeek()
				if (code == 1) {
					this.goods_ids = data.goods_ids
					this.getDataGoodList(data.goods_ids)
					this.continue_days = data.continue_days
					this.rules = data.rules
					this.days = this.getComputed(data.days)
					const createDayObject ={
						"is_sign": 0,
						"is_replenish": 0,
						"date": "",
						"time": 1732723200,
						"day": 28,
						"week": "",
						"current": ""
					};
					if (this.days.length < 28) {
						while (this.days.length < 28) {
						    arr.push(createDayObject);
						}
						    
						return
					}

					if (this.days.length >= 28) {
						this.days = this.days.slice(0,28)
					}

				}
			},
			getDataGoodList(ids) {
				getGoodsIds(ids).then(res => {
					if (res.code == 1) {
						this.redList = res.data
					}
				})
			},
			end(e) {
				this.endShow = true
			},
			receive() {
				this.endShow = false
				let indexNum = uni.getStorageSync('indexNum')
				let nums = Number(indexNum) + 1
				uni.setStorage({
					key: 'indexNum',
					data: nums
				})
				if (this.time[nums]) {
					this.timestamp = this.time[nums].timestamp
					this.num = this.time[nums].num
				} else {
					this.showTitle = true
					uni.showToast({
						title: '已全部领取',
						icon: 'none'
					})
				}
			},
			getDataMonth() {
				const date = new Date();
				const year = date.getFullYear();
				const month = ('0' + (date.getMonth() + 1)).slice(-2); // 月份要加1，且补零处理
				const day = ('0' + date.getDate()).slice(-2); // 补零处理
				let currentDate = `${year}-${month}-${day}`
				return currentDate
			},
			async submitWeek() {
				let {
					code,
					data,
					msg
				} = await getActivitySigninSignin()
				if (code == 1) {
					this.getDataWeek()
					this.getUserInfo()
				}
				uni.showToast({
					title: msg,
					icon: 'none'
				})

			},

		}
	}
</script>

<style lang="scss" scoped>
	.contents {
		width: 100%;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
	}

	.items {
		width: calc(100% / 3);
		/* 间隙为5px */
	}

	.top {
		background-image: linear-gradient(#ff8067, #fecca5);
		padding-bottom: 30rpx;
	}

	.iconBtn {
		background-image: linear-gradient(#ff9595, #fe3737);
		color: #fff;
		padding: 8rpx 15rpx;
		border-top-right-radius: 25rpx;
		border-top-left-radius: 25rpx;
		border-bottom-right-radius: 25rpx;
		font-size: 22rpx;
		position: absolute;
		top: -25rpx;
		right: -5rpx;
	}

	/*秒杀商品*/
	.tui-goods__list {
		display: flex;
		align-items: center;
	}

	.tui-goods__item {
		background-color: #fff;
		width: 120rpx;
		height: 130rpx;
		border-radius: 20rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-direction: column;
		flex-shrink: 0;
		margin-right: 10rpx;
		padding: 0 5rpx;
	}

	.tui-goods__imgbox {
		width: 100rpx;

		box-sizing: border-box;
		background: #b2eeff;
		padding-bottom: 3rpx;
		color: #3593ff;
		display: flex;
		align-items: center;
		justify-content: center;
		border-bottom-right-radius: 20rpx;
		border-bottom-left-radius: 20rpx
	}

	.tui-goods__img {
		max-width: 120rpx;
		display: block;
	}

	.tui-pri__box {
		max-width: 100rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.tui-sale-pri {
		display: flex;
		align-items: flex-end;
		padding: 10rpx 0 8rpx;
		box-sizing: border-box;
		font-size: 28rpx;
		line-height: 28rpx;
		color: #eb0909;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
	}

	.tui-size-sm {
		font-size: 24rpx;
		line-height: 24rpx;
		transform: scale(0.8);
		transform-origin: 0 50%;
	}

	.tui-original__pri {
		font-size: 24rpx;
		line-height: 24rpx;
		color: #999999;
		transform-origin: center 10%;
		transform: scale(0.8);
		display: flex;
		align-items: center;
		justify-content: center;
		text-decoration: line-through;
	}

	.acIcon {
		background: red;
		border-radius: 50%;
		width: 25rpx;
		height: 25rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute;
		right: -15rpx;
	}


	.tui-product-box {
		// margin-top: 20rpx;
		padding: 0 25rpx;
		box-sizing: border-box;
	}



	.tui-size-sm {
		font-size: 24rpx;
		line-height: 24rpx;
		transform: scale(0.8);
		transform-origin: 0 50%;
	}

	.tui-original__pri {
		font-size: 24rpx;
		line-height: 24rpx;
		color: #999999;
		transform-origin: center 10%;
		transform: scale(0.8);
		display: flex;
		align-items: center;
		justify-content: center;
		text-decoration: line-through;
	}

	/*秒杀商品*/

	.tui-more__box {
		display: flex;
		align-items: center;
		font-weight: 400;
		color: #999;
	}

	.tui-more__box text {
		font-size: 24rpx;
		line-height: 24rpx;
	}

	.tui-new-box {
		display: flex;
		align-items: center;
		justify-content: space-between;
		flex-wrap: wrap;
	}

	.tui-new-item {
		width: 49%;
		height: 180rpx;
		padding: 0 20rpx;
		box-sizing: border-box;
		display: flex;
		align-items: center;
		background: #f5f2f9;
		position: relative;
		border-radius: 12rpx;
	}

	.tui-new-mtop {
		margin-top: 2%;
	}

	.tui-title-box {
		font-size: 24rpx;
	}

	.tui-new-title {
		font-size: 26rpx;
		line-height: 32rpx;
		word-break: break-all;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}



	.tui-new-label {
		width: 56rpx;
		height: 56rpx;
		border-top-left-radius: 12rpx;
		position: absolute;
		left: 0;
		top: 0;
	}

	.tui-title__img {
		width: 100%;
		padding: 30rpx 0;
		display: flex;
		justify-content: center;
	}

	.tui-title__img image {
		width: 352rpx;
		height: 32rpx;
	}

	.tui-product-list {
		display: flex;
		justify-content: space-between;
		flex-direction: row;
		flex-wrap: wrap;
		box-sizing: border-box;
		/* padding-top: 20rpx; */
	}

	.tui-product-container {
		flex: 1;
		margin-right: 2%;
	}

	.tui-product-container:last-child {
		margin-right: 0;
	}

	.tui-pro-item {
		width: 100%;
		margin-bottom: 4%;
		background: #fff;
		box-sizing: border-box;
		border-radius: 12rpx;
		overflow: hidden;
	}

	.tui-pro-img {
		width: 100%;
		display: block;
	}

	.tui-pro-content {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		box-sizing: border-box;
		padding: 20rpx;
	}

	.tui-pro-tit {
		color: #2e2e2e;
		font-size: 26rpx;
		line-height: 32rpx;
		word-break: break-all;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
		-webkit-line-clamp: 2;
	}

	.tui-pro-price {
		padding-top: 18rpx;
	}

	.tui-sale-price {
		font-size: 34rpx;
		font-weight: 500;
		color: #e41f19;
	}

	.tui-factory-price {
		font-size: 24rpx;
		color: #a0a0a0;
		text-decoration: line-through;
		padding-left: 12rpx;
	}

	.tui-pro-pay {
		padding-top: 10rpx;
		font-size: 24rpx;
		color: #656565;
	}


	.unicorn-font-size {
		font-size: 35rpx;
		font-weight: 700;
	}

	.unicorn-border-radius-swiper {
		border-radius: 10px;
	}

	.unicorn-body {
		padding: 0rpx 15rpx;
	}

	.unicorn-image {
		width: 60rpx;
		height: 60rpx;
		margin-bottom: 10rpx;
	}

	.timeResult {
		background: rgb(240, 242, 244);
		color: #000;
	}

	.activetimeResult {
		background: #fe6100;
		color: #fff;
	}
</style>